package cn.wolfcode.luowowo.order.domain;



import cn.wolfcode.luowowo.article.domain.Ticket;
import cn.wolfcode.luowowo.member.domain.UserInfo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Getter;
import lombok.Setter;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

@Setter
@Getter
@Document("ticket_order")
public class TicketOrder implements Serializable {

    public static final int ORDER_STATE_SUCCESS = 1;
    public static final int ORDER_STATE_FAIL = 0;
    @Id
    private String id;
    //产品编号
    private String pno;
    //产品名称
    private String pnName;
    //产品数量
    private int ordrNum;
    //取票人信息
    private String username;
    //用户手机号
    private String phone;
    //游客类型
    private int peopleType;
    //用户身份证号
    private String inNo;

    //访问时间
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date visitTime;
    private UserInfo userInfo;
    private String orderNO;
    private int state = ORDER_STATE_FAIL;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date createTime;

    public String getPeopleType(){
        if(peopleType== Ticket.TICKET_PEOPLE_TYPE_ADULT){
            return "成人票";
        }else if(peopleType== Ticket.TICKET_PEOPLE_TYPE_CHIRLD){
            return "儿童票";
        }else if(peopleType== Ticket.TICKET_PEOPLE_TYPE_OLDER){
            return "老人票";
        }else {
            return "学生票";
        }
    }
}
